package nowcoder;
/**
 * -另类加法
 * 链接：https://www.nowcoder.com/practice/e7e0d226f1e84ba7ab8b28efc6e1aebc?tpId=8&&tqId=11065&rp=1&ru=/activity/oj&qru=/ta/cracking-the-coding-interview/question-ranking
 */

import java.util.*;

public class Day09_1 {
    public int addAB(int A, int B) {
        if (B == 0) {
            return A;
        }
        int sum = 0;
        int carray = 0;
        while (B != 0) {
            sum = A ^ B;
            carray = (A & B) << 1;
            A = sum;
            B = carray;
        }
        return A;
    }
}
